<template>
  <div class="tabbar">
    <div
      v-for="(item, index) in tabbar"
      :key="index"
      :class="index == currentIndex ? 'tabbar-item current' : 'tabbar-item'"
      @click="changeIndex(index)"
    >
      {{ item }}
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentIndex: 1,
      tabbar: ["已借出", "已借到", "历史记录"],
    };
  },
  methods: {
    changeIndex(index) {
      this.currentIndex = index;
      this.$emit("changeIndex", index);
    },
  },
};
</script>

<style scoped>
.tabbar {
  background-color: #5a78ec;
  height: 2.75rem;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding-bottom: 0.3125rem;
}
.tabbar-item {
  color: #ffffff;
  font-size: 0.75rem;
  padding: 0 0.3125rem;
}
.current {
  font-size: 0.8125rem;
  border-bottom: 0.25rem solid #ffffff;
}
</style>